<?php

namespace controller;

/**
 * Kontroler odpowiedzialny za zarządzanie plikami użytkownika
 *
 * @author Damian
 */
class ShopAdmin_Files extends Seller{
    public function index() {
        $session = \library\Registry::get("session");
       $shop = $session->get("shop");
       $pictureCriteria = new \model\Criteria();
       $pictureCriteria->from(\model\TblPicture::getModel()->getTable())
                ->where(\model\TblPicture::SHOP_ID, "=",  $this->shop->ShopID)
                ->where(\model\TblPicture::DELETED, "=", 0,false, " and ");
        $files = \model\TblPicture::getModel()->all($pictureCriteria);
        
        if ($files){
            $view = $this->getActionView();
            $view->set("shopname",  $this->shop->Name);
            $filesDataTable = new \model\DataTable($files);
            $view->set("files",$filesDataTable->getModelData(true));
        }
        $layoutView = $this->getLayoutView();
        $layoutView->set("paneltitle","Lista Twoich plików");
            $this->render();
    }
    public function add(){
        $layoutView = $this->getLayoutView();
        $layoutView->set("paneltitle","Wyślij pliki");
        $view = $this->getActionView();
        $view->set("sellerid",  $this->shop->ShopID);
        $view->set("shopname",  $this->shop->URL);
        $this->render();
    }
}
